﻿/*
 * DataTable拓展JQuery
 * version:1.0
 */
if (typeof window.DataTable != 'undefined') {
    Messages.Alert("DataTable 拓展关键字已经被占位");
}
else {
    window.DataTable = DataTableObj;
    console.log("DataTable拓展 加载成功！");
    function DataTableObj(option) {
        if (typeof option == 'undefined') {
            return;
        }
        if (typeof option.Type == "undefined") {
            option.Type = "1";
        }
        if (option.Type == "1") {
            var cols = option.cols;
            var data = option.data;
            //重构后
            //$(option.dom).App
            var html = "<table class='cont_list' cellspacing='0' border = '1' style='width:100%;border-collapse:collapse;margin:0;'>";
            html += "<tbody>";
            html += "<tr>";
            for (var i = 0; i < cols.length; i++) {
                html += "<th>" + cols[i].Text + "</th>";
            }
            html += "</tr>";
            for (var i = 0; i < data.length; i++) {
                var itemhtml = "<tr onmouseover=\"cu=style.backgroundColor;style.backgroundColor='#d5e7ff'\" onmouseout='style.backgroundColor=cu'>";
                for (var j = 0; j < cols.length; j++) {
                    if (typeof cols[j].Format == 'undefined') {
                        itemhtml += "<td>" + data[i][cols[j].Name] + "</td>";
                    }
                    else {
                        itemhtml += "<td>" + cols[j].Format(data[i], j) + "</td>";
                    }
                }
                itemhtml += "</tr>";
                html += itemhtml;
            }
            html += "</tbody>";
            html += "</table>";
            $(option.dom).html(html);
            return;
        }
    }
}
/*
 * AJAX拓展
 */
if (typeof window.Master != 'undefined') {
    if (typeof window.Master.Ajax == 'undefined') {
        window.Master.Ajax = $.ajax;
        console.log("AJAX拓展 加载成功！");
    }
}